// 简单的Mock数据测试
import Mock from 'mockjs'

// 随机图片服务
const getRandomImage = (width, height, category = '') => {
  const baseUrl = 'https://images.unsplash.com'
  const categories = {
    drama: [
      'photo-1529626455594-4ff0802cfb7e',
      'photo-1535713875002-d1d0cf377fde',
      'photo-1507003211169-0a1dd7228f2d',
      'photo-1438761681033-6461ffad8d80',
      'photo-1508214751196-bcfd4ca60f91',
      'photo-1518676590629-3dcbd9c5a5c9',
      'photo-1544725176-7c40e5a71c5e',
      'photo-1573496359142-b8d87734a5a2',
      'photo-1507003211169-0a1dd7228f2d',
      'photo-1536440136628-849c177e76a1'
    ],
    avatar: [
      'photo-1535713875002-d1d0cf377fde',
      'photo-1507003211169-0a1dd7228f2d',
      'photo-1438761681033-6461ffad8d80',
      'photo-1508214751196-bcfd4ca60f91'
    ]
  }

  const imageIds = categories[category] || categories.drama
  const randomId = imageIds[Math.floor(Math.random() * imageIds.length)]

  return `${baseUrl}/${randomId}?w=${width}&h=${height}&fit=crop`
}

// 追剧页面数据
const generateBingewatchData = () => {
  return Mock.mock({
    msg: '成功',
    code: 200,
    data: {
      'following|3': [
        {
          'id|+1': 500,
          title: '@ctitle(8, 15)',
          cover: () => getRandomImage(150, 200, 'drama'),
          currentEpisode: '@integer(1, 50)',
          totalEpisodes: '@integer(12, 100)',
          description: '观看至第' + '@integer(1, 50)' + '集',
          progress: '@integer(0, 100)',
          'isLiked|1': [true, false],
          'isStarred|1': [true, false],
          lastWatchTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
          'status|1': ['watching', 'completed']
        }
      ],
      'history|5': [
        {
          'id|+1': 600,
          title: '@ctitle(6, 12)',
          cover: () => getRandomImage(120, 160, 'drama'),
          currentEpisode: '@integer(1, 50)',
          totalEpisodes: '@integer(12, 100)',
          watchTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
          duration: '@integer(600, 3600)',
          progress: '@integer(0, 100)',
          'isLiked|1': [true, false],
          'isStarred|1': [true, false],
          watchedAt: '@datetime("yyyy-MM-dd HH:mm:ss")',
          'status|1': ['watching', 'completed']
        }
      ]
    }
  })
}

console.log('=== 追剧页面Mock数据测试 ===')
const result = generateBingewatchData()
console.log(JSON.stringify(result, null, 2))

console.log('\n=== 字段验证 ===')
console.log('Following 字段:', Object.keys(result.data.following[0]))
console.log('History 字段:', Object.keys(result.data.history[0]))
